<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>担保人考察照片列表</title>
<jsp:include page="../../import.jsp" flush="true" />
<script type="text/javascript">
var prjId='${prjId}'
var detailFlag='${detailFlag}'
var defImg = '${defImg}';
var prjCstId = '${prjCstId}';
var cstTypCd = '${cstTypCd}';
	var grid = null;
	$(function () {
	});
	function uploadFile(imgObj,sysCd,orgCd,cfgCd,cfgDtlCd){
		var obj = $(imgObj).parent().parent().find("img")
		var  url = '<%=path%>/project/prjbscinfo/addGuarSurveyInvestImgPage.do?sysCd='+sysCd+'&&orgCd='+orgCd+'&&cfgCd='+cfgCd+'&&cfgDtlCd='+cfgDtlCd+'&&prjId='+prjId+'&&prjCstId='+prjCstId;
		$.ligerDialog.open({
            height:300,
            width: 600,
            title : '上传图片',
            url: url, 
            showMax: false,
            showToggle: true,
            showMin: false,
            isResize: true,
            slide: false,
            data: {
            	imgObj: obj
            },
        });

		
	}
	function removeFileRec(imgObj,id){
	/* 	if(!id){
			$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_MORE_ROW , SQ_type: "warning" });
			return;
		} */
		var obj = $(imgObj).parent().parent().find("img");
		var fileId = obj.attr("fileId");
		$.ligerDialog.confirm('确定删除吗?', function (flag) {
			if(flag == false)return;
			var wait_dialog;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{id:fileId},
				url: '<%=path%>/system/sysulfilesrec/removeById.do',
				beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			     },
				success:function(msg){
					wait_dialog.close();
					 if(msg.success == 1){
							var obj = $(imgObj).parent().parent().find("img");
						// var imgPath = "http://10.10.36.18:80/attachments/default/placeholder.png";
						 var imgPath=defImg;
 						  obj.attr("src",imgPath);
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
						 
					 }else{
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			});
		});
	}
	function showImg(e){
		 e.preventDefault();
		   var href = $(e.target).attr('src');
		      if(!href){
		    	  return;
		      }
		      if(SQ.regs.img.test(href)){
         var imgSrc = $(e.target).attr('src'),
             imgTit = $(e.target).attr('title');
         window.__ImgSrc = imgSrc;
         window.__ImgTit = imgTit;
         window.open('<%=path%>/project/prjbscinfo/imgWinOpen.do', '', 'location=yes, width=800, height=600');
		      }
/* 		 e.preventDefault();
      var href = $(e.target).attr('href');
      if(!href){
    	  return;
      }
      if(SQ.regs.img.test(href)){
          SQ.imgPreview(href);
      } */
	}
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
</script>
</head>
<body class="iframeBody">
<div class="Wrapper">
 <div id="pageInTab" class="pageInTab">
  			 <div class="sqPanel">
		            <div class="sqPanel_head inL">
		                <span>担保人考察</span>
		            </div>
		            <table class="table_full tbl_1">
			            <tbody>
						   <tr>  
							    <c:forEach items="${dtlList}" var="cstFile" varStatus="status">  
							        <c:if test="${status.index%4==0}">  
							            </tr>  
							            <tr>  
							        </c:if>  
								 <td>
									  <h5>${cstFile.datNm}</h5>
									  <div class="imgBox">
									  <c:if test="${ empty cstFile.filePath}">
									  <img src="${defImg}"  onclick="showImg(event);" fileId="">
									  </c:if>
									<c:if test="${ not empty cstFile.filePath}">
									  <img id="imgPath" src="${cstFile.filePath}"  fileId="${cstFile.id}" onclick="showImg(event);" href="${cstFile.filePath}">
									</c:if>
									  </div>
									    <div class="btns">
						                    <span  class="sq-button sq-button-round"  sysCd="${cstFile.sysCd}" orgCd="${cstFile.orgCd}" cfgCd="${cstFile.cfgCd}" cfgDtlCd="${cstFile.cfgDtlCd}" <%-- cfgDtId="${cstFile.cfgDtId}"  --%> onclick="uploadFile(this,'${cstFile.sysCd}','${cstFile.orgCd}','${cstFile.cfgCd}','${cstFile.cfgDtlCd}')">上传</span>
						                      <a   class="sq-button sq-button-round"  target="_blank"  href="<%=path%>/system/sysulfilesrec/downLoad.do?fileName=${cstFile.fileNm}&filePath=${cstFile.filePath}">下载</a>
					                    </span>
						                    <span class="sq-button sq-button-round" onclick="removeFileRec(this,'${cstFile.id}')">删除</span>
                						</div>
							      </td>  
							    </c:forEach>  
							</tr> 
			            </tbody>
		            </table>
  			 </div>   
   
   </div>
</div>
</body>
</html>